package com.AdvancedDemos.接口.学生信息接口案例;

import java.util.ArrayList;

public class StudentOperatorImpl1 implements StudentOperator {

    /**
     * 打印班级学生信息
     *
     * @param students
     */
    @Override
    public void printAllInfo(ArrayList<Student> students) {
        System.out.println("----全班全部学生信息如下----");
        for (int i = 0; i < students.size(); i++) {
            Student temp = students.get(i);
            System.out.println("姓名:" + temp.getName() + ",性别:" + temp.getGender() + ",成绩:" + temp.getScore());
        }
        System.out.println("------------------------");
    }

    /**
     * 打印总体的平均分
     *
     * @param students
     */
    @Override
    public void printAverageScore(ArrayList<Student> students) {
        double allScore = 0.0;
        for (int i = 0; i < students.size(); i++) {
            Student temp = students.get(i);
            allScore += temp.getScore();
        }
        System.out.println("平均分是:" + (allScore / students.size()));
    }
}
